#ifndef PARAFLUIDTRIANGLE_H
#define PARAFLUIDTRIANGLE_H

#include "parafluidsegment.h"
#include "parafluidvector.h"

namespace ParaFluid
{
	
	/**
	* Triangle
	*/
	class Triangle
	{
		
	public:
		
		/**
		* Destructor
		*/
		~Triangle();
		
		/**
		* Default Constructor
		*/
		Triangle();
		
		/**
		* Copy Constructor
		*/
		Triangle(const Triangle & other);
		
		/**
		* Constructor with three Points
		*/
		Triangle(const Vector & point1, const Vector & point2, const Vector & point3);
		
		/**
		* Assignment Operator
		*/
		Triangle & operator= (const Triangle & rhs);
		
		/**
		* Getter for Point 1
		*/
		const Vector & point1() const;
		
		/**
		* Getter for Point 2
		*/
		const Vector & point2() const;
		
		/**
		* Getter for Point 3
		*/
		const Vector & point3() const;
		
		/**
		* Getter for Normal
		*/
		const Vector & normal() const;
		
		/**
		* @return TRUE if Triangle is Degenerate (made of colinear points)
		*/
		bool isDegenerate() const;
		
		/**
		* Compute the intersection point with a Segment
		* @param point Intersection point
		* @return TRUE if the specified Segment intersects with this Triangle
		*/
		bool intersects(const Segment & segment, Vector & point) const;
		
	private:
		
		/**
		* Compute Normal
		*/
		void computeNormal() const;
		
		/**
		* Point 1
		*/
		Vector _point1;
		
		/**
		* Point 2
		*/
		Vector _point2;
		
		/**
		* Point 3
		*/
		Vector _point3;
		
		/**
		* Was Normal Computed?
		*/
		mutable bool _normalComputed;
		
		/**
		* Normal
		*/
		mutable Vector _normal;
		
		/**
		* Triangle is Degenerate
		*/
		mutable bool _degenerate;
		
	};
	
}

#endif
